﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CloudStorage_Backend.utils
{
    public class ResponseResult<T>
    {
        public int Code { get; set; }
        public string Message { get; set; }
        public T Data { get; set; }

        public ResponseResult() { }

        public static ResponseResult<string> Ok()
        {
            return new ResponseResult<string>
            {
                Code = (int)ResultCode.SUCCESS,
                Message = "请求成功",
            };
        }

        public static ResponseResult<T> Ok(T data)
        {
            return new ResponseResult<T>
            {
                Code = (int)ResultCode.SUCCESS,
                Message = "请求成功",
                Data = data
            };
        }
        
        public static ResponseResult<T> Error(ResultCode resultCode, string message) {
            return new ResponseResult<T> {
                Code = (int)resultCode,
                Message = message
            };
        }
    }
    public enum ResultCode
    {
       SUCCESS = 200,
       BAD_REQUEST = 400,
       NOT_FOUND = 404,
       UNKNOWN_ERROR = 999,

       USER_NOT_FOUND = 1404,
       NAME_OR_PASSWORD_WRONG = 1400,
       NAME_HAS_BEEN_USED = 1401,

       FILE_NOT_FOUND = 2404,
       DIRECTORY_NOT_FOUND = 3404,
       FILE_HAS_EXIST = 2401,
       FILE_TOO_LARGE = 2400,
       INVALID_DIRECTORY_NAME = 2406,

       EMPTY_UPLOAD_REQUEST = 3400,
       CHUNK_OVERFLOW = 3401,
       FILECHUNKSIZE_WRONG = 3402,
       LASTCHUNK_WRONG = 3403,
       SINGLECHUNK_WRONG = 3405,
       WRONG_PATH_FORMAT = 3406
    }
}
